09. CODE: Writing the A* Heuristic
Writing the A* Heuristic
L2 Writing The A- Heuristic
Writing the
Heuristic()
function
In this quiz, you will write a
Heuristic
function that will be used to guide the A* search. In general, any
admissible function
can be used for the heuristic, but for this project, you will write one that takes a pair of 2D coordinates on the grid and returns the
Manhattan Distance
from one coordinate to the other.
To Complete This Exercise:
- Write an
int Heuristicfunction which takes fourints as arguments. Theints represent two pairs of 2D coordinates: (x_1, y_1, x_2, y_2) . The function should return anintwhich is the Manhattan Distance from one coordinate to the other: |x_2- x_1| + |y_2 - y_1| .
Workspace
This section contains either a workspace (it can be a Jupyter Notebook workspace or an online code editor work space, etc.) and it cannot be automatically downloaded to be generated here. Please access the classroom with your account and manually download the workspace to your local machine. Note that for some courses, Udacity upload the workspace files onto https://github.com/udacity , so you may be able to download them there.
Workspace Information:
- Default file path:
- Workspace type: generic
- Opened files (when workspace is loaded): n/a
-
userCode:
export CXX=g++-7
export CXXFLAGS=-std=c++17
g++() {
/usr/bin/g++-7 -std=c++17 "$1"
}
export -f g++